<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<head>

</head>

<body>

	<ui:composition template="../WEB-INF/layout/template.xhtml">
		<ui:define name="title">
			<h:outputText value="#{msg.add_student}" />
		</ui:define>
		<ui:define name="content">

			<div style="width: 750px; margin: auto;">
				<p:tabView>
					
					<p:tab title="B">
						<h:form id="tableForm">
							<p:dataTable id="table" value="#{testBean.foos}" var="foo">
								<p:column>
									<f:facet name="header">
										<h:outputText value="Temp" />
									</f:facet>
									<h:outputText value="#{foo.temp}" />
								</p:column>
							</p:dataTable>
						</h:form>
						<h:outputText id="out" value="Hello, #{testBean.tempFoo.temp}!!!" />
						<p:panel id="panel">
							<h:form id="pform">
								<p:commandButton id="loginLink" value="SHOW"
									onclick="dlg.show()" />
							</h:form>
						</p:panel>
					</p:tab>
				</p:tabView>

				<p:dialog id="dialog" header="Login" widgetVar="dlg" modal="true">
					<h:form id="form">
						<p:growl id="growl" showDetail="true" life="3000" />
						<h:panelGrid columns="3" cellpadding="5">
							<h:outputLabel for="temp" value="temp *" />
							<p:inputText value="#{testBean.tempFoo.temp}" id="temp"
								required="true" label="temp" />
							<p:message for="temp" />
							<f:facet name="footer">
								<p:commandButton value="ADD" actionListener="#{testBean.add}"
									update="form tableForm:out tableForm:table"
									oncomplete="handleLoginRequest2(xhr, status, args)" />
							</f:facet>
						</h:panelGrid>
					</h:form>
				</p:dialog>
				
				

				<script type="text/javascript">
					function handleLoginRequest2(xhr, status, args) {
						if(args.validationFailed) {
							jQuery('#dialog').effect("shake", { times:3 }, 100);
						} else {
							dlg.hide();
							document.forms['form'].reset();			
						}
					}
				</script>
			</div>
		</ui:define>
	</ui:composition>
</body>
</html>
